function createValidate() {
    let validate = function ({ rule, message = '', value }) {
        let result = true;
        value += '';
        Object.assign(validate, { rule, message, aim: value });
        switch (typeof rule) {
            case 'string':
            case 'number':
                if (rule != value) {
                    result = false;
                }
                break;
            case 'object':
                if (rule instanceof RegExp) {
                    if (!rule.test(value))
                        result = false;
                    break;
                }
            default:
                throw new Error('rule类型错误，必须是正则对象、字符串、数字之一。');
        }
        if (!result)
            validate.message = message;
        return result;
    };
    return validate;
}
let cddValidate = createValidate();
export default cddValidate;
